package cn.edu.ren.feign.imp;

import cn.edu.ren.feign.IStudentFeign;
import cn.edu.ren.pojo.Student;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * @PackageName: cn.edu.ren.feign.imp
 * @ClassName: UserRemoteClientFallbackFactory
 * @Description:
 * @author: RZS
 * @date: 2021/6/27  12:08
 */
@Component
public class UserRemoteClientFallbackFactory implements FallbackFactory<IStudentFeign> {

    private Logger logger = LoggerFactory.getLogger(UserRemoteClientFallbackFactory.class);

    @Override
    public IStudentFeign create(final Throwable cause) {
        logger.error("UserRemoteClient回退：", cause);
        return new IStudentFeign() {
            @Override
            public Collection<Student> findAll() {
                return null;
            }

            @Override
            public String index() {
                return "FallbackFactory 方式, 网络与服务器失去联系了....";
            }
        };
    }

}
